package com.zhuizikejithreeig.cn.threeigkeji.mianinfo;

import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.flyco.tablayout.SlidingTabLayout;
import com.zhuizikejithreeig.cn.adapter.NotPagerAdapter;
import com.zhuizikejithreeig.cn.fragment.PagerFragemnt;
import com.zhuizikejithreeig.cn.threeigkeji.BasicActivity;
import com.zhuizikejithreeig.cn.threeigkeji.R;
import com.zhuizikejithreeig.cn.utils.AndroidWorkaround;
import com.zhuizikejithreeig.cn.weigit.NoScrollViewPager;

import java.util.ArrayList;

public class EmailActivity extends BasicActivity {

    private final String[] title = {"通知", "活动"};
    private RelativeLayout mLeft;
    private ArrayList<Fragment> mFragments = new ArrayList<>();
    private SlidingTabLayout  mTabLayout;
    private NoScrollViewPager mViewPager;
    private NotPagerAdapter   mAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView_V(R.layout.activity_email);
        showBody();
        mLeft = (RelativeLayout)findViewById(R.id.mleft);
        mTabLayout = (SlidingTabLayout)findViewById(R.id.slidingtablayout);
        mViewPager = (NoScrollViewPager)findViewById(R.id.viewpager);

        //设置返回按钮
        mLeft.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        for (int i = 1; i < title.length+1; i++) {
            mFragments.add(PagerFragemnt.getInstance(i+ ""));
        }

        //一句代码就可以控制是否滑动
        mViewPager.setNoScroll(true);
        mAdapter = new NotPagerAdapter(getSupportFragmentManager(), mFragments, title);
        mViewPager.setAdapter(mAdapter);
        mTabLayout.setViewPager(mViewPager, title);
    }

}
